home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
System
/
Bond FBA
/
CheapSound.p
< prev
next >
Wrap
Text File
|
1996-05-04
|
2KB
|
79 lines
unit CheapSound;
interface
uses
Sound;
procedure TerminateSound;
procedure PlaySound (mySndID: Integer);
procedure PlayNamedSound (name: Str255);
function SoundPlaying: Boolean;
implementation
{------------ New routines -------------}
var
mySndChan, mySndChan2: SndChannelPtr;
const
kAsync = true;
procedure TerminateSound;
var
myErr: OSErr;
begin
if mySndChan <> nil then
myErr := SndDisposeChannel(mySndChan, TRUE);
if mySndChan2 <> nil then
myErr := SndDisposeChannel(mySndChan2, TRUE);
mySndChan := nil;
mySndChan2 := nil;
end;
function QChanBusy (chan: SndChannelPtr): Boolean;
var
theLength: Integer;
theStatus: SCStatus;
begin
if chan = nil then
QChanBusy := false
else if noErr <> SndChannelStatus(chan, SizeOf(SCStatus), @theStatus) then
QChanBusy := chan^.QHead <> -1 {Didn't work, go back to old way}
else
QChanBusy := theStatus.scChannelBusy;
end;
function SoundPlaying: Boolean;
begin
SoundPlaying := QChanBusy(mySndChan);{ or QChanBusy(mySndChan2)}
end;
procedure PlaySound (mySndID: Integer);
var
myErr: OSErr;
mySndHandle: Handle;
begin
TerminateSound;
mySndChan := nil;
myErr := SndNewChannel(mySndChan, 0, 0, nil);
mySndHandle := GetResource('snd ', mySndID);
HLock(mySndHandle);
myErr := SndPlay(mySndChan, mySndHandle, kAsync);
end;
procedure PlayNamedSound (name: Str255);
var
myErr: OSErr;
mySndHandle: Handle;
begin
TerminateSound;
mySndChan := nil;
myErr := SndNewChannel(mySndChan, 0, 0, nil);
mySndHandle := GetNamedResource('snd ', name);
HLock(mySndHandle);
myErr := SndPlay(mySndChan, mySndHandle, kAsync);
end;
end.